package models

import "gorm.io/gorm"

type Member struct {
	gorm.Model
	Title string `gorm:"type:varchar(20);not null;comment:会员套餐"`
	Price int    `gorm:"type:int(11);not null;comment:金额"`
	Time  int    `gorm:"type:int(11);not null;comment:会员天数"`
}

type MemberOrder struct {
	gorm.Model
	UserId   int    `gorm:"type:int(11);not null;comment:用户id"`
	MemberId int    `gorm:"type:int(11);not null;comment:会员套餐id"`
	OrderOn  string `gorm:"type:varchar(50);not null;comment:订单号"`
	PayType  int    `gorm:"type:tinyint;not null;comment:支付方式 0:支付宝 1:微信 2:银联"`
}

func (m *Member) ShowMember() error {
	return DB.Debug().Where("id = ?", m.ID).Find(&m).Error
}

func (m *Member) AddMember() error {
	return DB.Debug().Create(&m).Error
}

func (o *MemberOrder) Createorder() error {
	return DB.Debug().Create(&o).Error
}
